﻿//-----------------------------------------------------------------------
// <copyright file="Then.cs" company="tuliprules.org">
//     Copyright (c) 2011 tuplelister, tuliprules.org.
// </copyright>
// <summary>This is the Then class.</summary>
//-----------------------------------------------------------------------
namespace Tulip.Rules.Models.Rif.Core
{
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Xml.Serialization;

    /// <summary>
    /// Represents a consequent role, containing ATOMIC or conjunction of ATOMICs.
    /// </summary>
    [Serializable]
    [DesignerCategory(@"code")]
    [XmlType(AnonymousType = true, Namespace = "http://www.w3.org/2007/rif#")]
    [XmlRoot(Namespace = "http://www.w3.org/2007/rif#", IsNullable = false)]
    public class Then : IRifCoreElement
    {
        /// <summary>
        /// The atom field.
        /// </summary>
        [EditorBrowsable(EditorBrowsableState.Never)]
        private Atom atomField;

        /// <summary>
        /// The frame field.
        /// </summary>
        [EditorBrowsable(EditorBrowsableState.Never)]
        private Frame frameField;

        /// <summary>
        /// The and field.
        /// </summary>
        [EditorBrowsable(EditorBrowsableState.Never)]
        private List<FormulaThenType> andField;

        /// <summary>
        /// Initializes a new instance of the <see cref="Then"/> class. 
        /// </summary>
        public Then()
        {
            this.andField = new List<FormulaThenType>();
        }

        /// <summary>
        /// Gets or sets an atom formula, positional or with named arguments.
        /// </summary>
        [XmlElement(Order = 0)]
        public Atom Atom
        {
            get
            {
                return this.atomField;
            }

            set
            {
                this.atomField = value;
            }
        }

        /// <summary>
        /// Gets or sets a frame formula.
        /// </summary>
        [XmlElement(Order = 1)]
        public Frame Frame
        {
            get
            {
                return this.frameField;
            }

            set
            {
                this.frameField = value;
            }
        }

        /// <summary>
        /// Gets or sets a conjunction.
        /// </summary>
        [XmlArrayAttribute(Order = 2)]
        [XmlArrayItemAttribute("formula", IsNullable = false)]
        public List<FormulaThenType> And
        {
            get
            {
                return this.andField;
            }

            set
            {
                this.andField = value;
            }
        }
    }
}
